package com.lucas.rpc.provider;

import com.lucas.rpc.common.rpc.interfaces.HelloService;
import com.lucas.rpc.framework.register.LocalRegister;
import com.lucas.rpc.framework.register.remote.MapRemoteRegister;
import com.lucas.rpc.framework.remote.URL;
import com.lucas.rpc.framework.transport.tomcat.TomcatServer;
import lombok.extern.slf4j.Slf4j;

/**
 * @author: LiuCheng
 * @description:
 * @date: 2023-11-27 17:19
 **/
@Slf4j
public class ProviderTomcatMain {

    public static void main(String[] args) throws Exception{

        //本地注册接口和不同版本的的实现类
        LocalRegister.register(HelloService.class.getName(),"1.0", HelloServiceImpl.class);
        LocalRegister.register(HelloService.class.getName(),"2.0", HelloServiceImpl2.class);

        //远程注册provider的地址
        URL url = new URL("localhost", 9999);
        MapRemoteRegister.register(HelloService.class.getName(),url);

        TomcatServer tomcatServer= new TomcatServer();
        tomcatServer.start(url.getHostname(),url.getPort());

    }
}
